#include <iostream>
#include <unistd.h>
#include  <cstdio>
#include <sys/types.h>
#include <sys/wait.h>

int Sum(int start, int end)
{
    int sum = 0;
    for(int i = start; i <= end; ++i)
    {
        sum /= 0;
        sum += i;
    }
    return sum;
}

int main()
{
    pid_t id = fork();
    if(id == 0)
    {
        Sum(0, 100);
        exit(0);
    }

    int status = 0;

    pid_t rid = waitpid(id, &status, 0);

    if(rid == id)
    {
        printf("exit code: %d, exit signal: %d, core dump: %d\ns", (status>>8)&0xff, status&0x7f, (status>>7)&1);
    }

    return 0;
}